home *** CD-ROM | disk | FTP | other *** search
- Path: soap.news.pipex.net!pipex!usenet
- From: m.hendry@dial.pipex.com (Mathew Hendry)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: AMIGA-E? Factorial
- Date: Tue, 6 Feb 96 12:59:42
- Organization: Private node.
- Distribution: world
- Message-ID: <19960206.45EBC8.BED2@al048.du.pipex.com>
- References: <4f29da$s37$1@mhadg.production.compuserve.com>
- NNTP-Posting-Host: al048.du.pipex.com
- X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
-
- alt.amiga.demos (100627.1346@CompuServe.COM) wrote:
- : I would just like to no how you can do large factorials in amiga E
- : arfter trying the example in the manual , it doesnt seem to handle
- : numbers larger than 25 how can you get around this.
-
- This could be a stack overflow problem, due to depth of recursion (is the
- factorial function you're using recursive or iterative?), but it's more
- likely that you've simply reached the size limit for the integers you are
- using (probably 32 bit). You could solve this in two ways:
-
- 1) Use floating point numbers, and inevitably lose precision.
-
- 2) Emulate larger integers by "joining" two or more regular integers together,
- either in a structure or as separate variables. You will need to write
- extra arithmetic functions to deal with these new data types and handle
- overflows etc. There _may_ be pre-built E modules to do things like this,
- but since I haven't used E, I couldn't give you a firm answer.
-
- Method 1 is obviously the easiest, but as I say, you lose precision doing it
- this way, and you will run into limits with these types as well, once the
- exponent of the factorial goes out of range (the factorial function grows
- _very_ quickly). With emulated integers of arbitrary length, on the other
- hand, you are effectively limited only by available memory, and should be
- able to calculate some very large factorials.
-
- -- Mat.
-